<template>
    <!--    <view class="cost-item">
        <view class="left-wrapper">
            <view class="index">{{ index + 1 }}</view>
            <view class="c-name" v-show="type == 2">
                {{ item.BName }}
            </view>
            <view class="c-name" v-show="type == 3">
                {{ item.EName }}
            </view>
            <view class="c-name" v-show="type == 5">
                {{ item.DName }}
            </view>
            <view class="c-name" v-show="type == 7">
                {{ item.PName }}
            </view>
        </view>
        <view class="right-wrapper">
            <view class="c-turnover" @click="goCommodity()">
                <view class="sum">{{ item.Qty }}</view>
            </view>
            <view class="c-turnover sale-money">
                <view class="sum">¥{{ item.Total }}</view>
            </view>
        </view>
    </view> -->
    <view class="new-cost-item">
        <view class="wrapper">
            <view class="between" @click="goUpDown(item)">
                <view class="c-name text-show-line-1" v-show="type == 2">
                    {{ item.BName }}
                </view>
                <view class="c-name text-show-line-1" v-show="type == 3">
                    {{ item.EName }}
                </view>
                <view class="c-name text-show-line-1" v-show="type == 5">
                    {{ item.DName }}
                </view>
                <view class="c-name text-show-line-1" v-show="type == 7">
                    {{ item.PName }}
                </view>
                <uni-icons v-if="item.IsLower == 1 || type == 3" type="forward" size="30"></uni-icons>
            </view>
            <view class="main" @click="goCommodity()">
                <view>销售量：{{ item.Qty }}</view>
                <view>销售额：{{ item.Total }}</view>
                <view>毛利：{{ item.IsMaori == 1 ? item.Maori : '-' }}</view>
                <uni-icons class="more" type="forward" size="30"></uni-icons>
            </view>
        </view>
    </view>
</template>

<script>
export default {
    components: {},
    props: {
        item: {
            type: Object,
            default: () => { },
        },
        index: {
            type: Number,
            default: 0,
        },
        type: {
            type: String / Number,
            default: 2,
        },
    },
    data() {
        return {}
    },
    mounted() { },
    onShow() { },
    methods: {
        goCommodity() {
            if (this.type == 7) {
                this.easyGoTo("/pages_erp/new-sale/commodity-list?type=" + this.type + '&goodcode=' + this.goCode())
            } else {
                this.easyGoTo("/pages_erp/new-sale/custom-list?type=" + this.type + '&code=' + this.goCode())
            }
        },
        goCode() {
            if (this.type == 2) {
                return this.item.BCode
            }
            if (this.type == 3) {
                return this.item.ECode
            }
            if (this.type == 5) {
                return this.item.DCode
            }
            if (this.type == 7) {
                return this.item.PCode
            }
        },
        goUpDown(item) {
            if (item.IsLower == 1 && (this.type == 2 || this.type == 5 || this.type == 7)) {//部门 客户 商品
                this.easyGoTo("/pages_erp/new-sale/index?type=" + this.type + '&code=' + this.goCode())
            }
            if (this.type == 3) {//业务员
                this.easyGoTo("/pages_erp/new-sale/salesman-product?name=" + encodeURIComponent(item.EName) + '&eCodeArr=' + item.ECode)
            }
        }
    },
}
</script>

<style lang="scss">
.cost-item {
    display: flex;
    justify-content: space-between;
    border-bottom: #ebebeb solid 1px;
    padding: 32rpx 60rpx 32rpx 0;
    margin-left: 48rpx;
    text-align: center;

    .left-wrapper,
    .right-wrapper {
        display: flex;
        flex: 1;
    }

    .right-wrapper {
        display: flex;
        justify-content: space-between;
        padding-left: 48rpx;

        .sale-money {
            margin-right: 24rpx;
        }
    }

    .c-name {
        flex: 1;
        word-break: break-all;
        text-align: left;
        margin-left: 48rpx;
        font-size: $size-28;
    }

    .c-turnover {
        .sum {
            font-size: $size-28;
        }

        .total {
            font-size: $size-24;
            color: $color-gray-3;
        }
    }

    .c-profit {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 180rpx;

        .perc {
            width: 136rpx;
            height: 46rpx;
            line-height: 46rpx;
            font-size: $size-28;
            background: #fff7eb;
            color: #ef9604;
        }
    }
}

.c-yellow {
    color: $color-yellow-1;
}

.new-cost-item {
    margin-bottom: 24rpx;

    .wrapper {
        background: $color-white;
        border-radius: 24rpx;
        padding: 24rpx;

        .between {
            display: flex;
            justify-content: space-between;
        }

        .c-name {
            font-size: 28rpx;
            font-weight: bold;
            margin-bottom: 24rpx;
        }

        .main {
            background: #F5F5F5;
            border-radius: 12rpx;
            padding: 24rpx 32rpx 8rpx 32rpx;
            display: flex;
            justify-content: flex-start;
            flex-wrap: wrap;
            position: relative;

            view {
                width: 50%;
                font-size: 28rpx;
                padding-bottom: 16rpx;
            }

            .more {
                position: absolute;
                right: 0;
                top: 40%;
            }
        }
    }
}
</style>
